#ifndef _HTML_TREE_H
#define _HTML_TREE_H

#include "html_link.h"

struct Tree_node{
	struct Html_node * element;
	struct Tree_node *child;
	struct Tree_node *sibling;
};

struct linked_list_tree_node{
	struct Tree_node *element;
	struct linked_list_tree_node *next;
};

struct linked_list_text_node{
	char *str;
	struct linked_list_text_node *next;
};

struct linked_list_attr_node{
	char *str;
	struct linked_list_attr_node *next;
};

/*
 * create a html tree
 */
void Create_tree(struct Tree_node **root,char *html_file);


/*
 * get the child node of the root
 */
struct Tree_node * get_child(struct Tree_node *root);

/*
 * get the sibling node of the root
 */

struct Tree_node *get_sibling(struct Tree_node *root);



/*
 * html_tree traversal
 */
 
void traversal_to_string(struct Tree_node *root,int depth);


/*
 * return the value of specified attr of a tree_node
 */

char * get_attr_value(struct Tree_node *root, char *attr_name);

/*
 *   return a pointer pointing to header of the linked list of specified attr_name
 */
void  get_attr_value_list(struct Tree_node *root,struct linked_list_attr_node **head, char *attr_name);

/*
 * return the text value if Tree_node->ellment->node_type == text
 */
char * get_text_value(struct Tree_node *root);

/*
 * return a pointer pointing to header of the linnked list of specified text
 */
void get_text_value_list(struct Tree_node *root,struct linked_list_text_node **head );



/*
 * return the pointer which points to the Tree_node whose start_tag is  my_tag,if there are a few Tree_node,return the header pointer of
 * the linked list
 */
void get_content_by_tag(struct Tree_node *root,struct linked_list_tree_node **head, char *my_tag);

/*
 * return the pointer which points to a Tree_node whose start_tag's attr's id == my_id
 */

struct Tree_node * get_content_by_id(struct Tree_node *root,char *my_id);

/*
 * free the memory of the html_tree
 */
void free_tree(struct Tree_node *root);

#endif
